package controllers

import config.{MyAwait, MyFile, MyRow, MyString}
import dao.{BlockDao, BlockRangeDao, GenomeDao, OgDao}
import play.api.libs.json.Json
import play.api.mvc.{AbstractController, ControllerComponents}

import javax.inject.Inject
import scala.concurrent.ExecutionContext

class OgController  @Inject()(ogDao: OgDao,
                              cc: ControllerComponents)
                             (implicit exec: ExecutionContext) extends AbstractController(cc) with MyAwait with MyFile with MyRow with MyString {


  def ogPage(og:String) =Action{implicit request=>
    Ok(views.html.og.ogPage(og))
  }

  def getDataByOg(og:String) = Action.async {implicit request=>
    ogDao.getByOg(og).map{x=>
      Ok(Json.toJson(x.map(_.getJsonByT())))
    }
  }

  def ogInfoPage(id:Int) = Action.async{implicit request=>
    ogDao.getById(id).map{x=>
      Ok(views.html.og.ogGenomePage(x))
    }
  }

}
